package CreatThreadPool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class demo2 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                3,
                5,
                8,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(4),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
                );

        threadPoolExecutor.execute(() -> System.out.println("执行该任务1"));
        threadPoolExecutor.execute(() -> System.out.println("执行该任务2"));
        threadPoolExecutor.execute(() -> System.out.println("执行该任务3"));
        threadPoolExecutor.execute(() -> System.out.println("执行该任务4"));
        threadPoolExecutor.execute(() -> System.out.println("执行该任务5"));
        threadPoolExecutor.execute(() -> System.out.println("执行该任务6"));

    }
}
